package com.yksj.healthtalk.utils;

import android.app.Activity;
import android.os.Bundle;

import com.open.share.OpenManager;
import com.open.share.interfaces.IOpenResponse;
import com.open.share.net.AbstractRunnable;
import com.open.share.net.NetPool;

/**
 *  分享
 * @author Administrator
 *
 */
public class ShareUtils {
	public static void share(int type,Bundle bundle,Activity activity,IOpenResponse response){
		OpenManager openManager = OpenManager.getInstatnce();
		AbstractRunnable runnable = null;
		boolean isEnable = OpenManager.getInstatnce().isVaild(type,activity);
		if(isEnable){
			if(bundle != null){
				boolean isImage = (bundle.containsKey(OpenManager.BUNDLE_KEY_IMGPATH)||bundle.containsKey(OpenManager.BUNDLE_KEY_PICURL));
				if(isImage){
					runnable = openManager.sharePhoto(type, bundle, response);
				}else{
					if(type == OpenManager.SINA_WEIBO){
						bundle.putString(OpenManager.BUNDLE_KEY_LATITUDE,"0.0");
						bundle.putString(OpenManager.BUNDLE_KEY_LONGITUDE,"0.0");
					}
					runnable = openManager.shareStatus(type,bundle,response);
				}
			}
			if(runnable != null)NetPool.getInstance().push(runnable);
			return;
		}else{//token 无效
			openManager.authorize(type, activity);
		}
	}
}
